<!-- This comment will put IE 6, 7 and 8 in quirks mode -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Código-Fonte de population.h</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Gerado por Doxygen 1.6.3 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Busca');
--></script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Página&nbsp;Principal</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Arquivos</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <img id="MSearchSelect" src="search/search.png"
             onmouseover="return searchBox.OnSearchSelectShow()"
             onmouseout="return searchBox.OnSearchSelectHide()"
             alt=""/>
        <input type="text" id="MSearchField" value="Busca" accesskey="S"
             onfocus="searchBox.OnSearchFieldFocus(true)" 
             onblur="searchBox.OnSearchFieldFocus(false)" 
             onkeyup="searchBox.OnSearchFieldChange(event)"/>
        <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
        </div>
      </li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>Lista&nbsp;de&nbsp;Arquivos</span></a></li>
      <li><a href="globals.html"><span>Arquivos&nbsp;Membros</span></a></li>
    </ul>
  </div>
<h1>population.h</h1><a href="population_8h.html">Vá para a documentação deste arquivo.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00008"></a>00008 <span class="preprocessor">#ifndef POPULATION_H</span>
<a name="l00009"></a>00009 <span class="preprocessor"></span><span class="preprocessor">#define POPULATION_H</span>
<a name="l00010"></a>00010 <span class="preprocessor"></span>
<a name="l00011"></a>00011 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;algorithm&gt;</span>
<a name="l00014"></a>00014 
<a name="l00015"></a>00015 <span class="preprocessor">#include &quot;<a class="code" href="coordinate_8h.html" title="Arquivo que contêm as definições da classe template coordinate.">coordinate.h</a>&quot;</span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &quot;<a class="code" href="individual_8h.html">individual.h</a>&quot;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &quot;<a class="code" href="definitions_8h.html">definitions.h</a>&quot;</span>
<a name="l00018"></a>00018 
<a name="l00019"></a>00019 <span class="comment">/* ----------------------------------------*/</span>
<a name="l00026"></a>00026 <span class="comment">/* ----------------------------------------*/</span>
<a name="l00027"></a>00027 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty = GAtype, <span class="keyword">typename</span> _realTy = GAreal_type&gt; <span class="keyword">class </span><a class="code" href="classpopulation.html">population</a>;
<a name="l00028"></a>00028 
<a name="l00029"></a>00029 <span class="comment">/* ----------------------------------------*/</span>
<a name="l00036"></a>00036 <span class="comment">/* ----------------------------------------*/</span>
<a name="l00037"></a>00037 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty = GAtype, <span class="keyword">typename</span> _realTy = GAreal_type&gt; <span class="keyword">class </span><a class="code" href="structpopulation__compare.html">population_compare</a>;
<a name="l00038"></a>00038 
<a name="l00039"></a>00039 
<a name="l00040"></a>00040 <span class="comment">/* --------------------------------------------------------------------------*/</span>
<a name="l00045"></a>00045 <span class="comment">/* ----------------------------------------------------------------------------*/</span>
<a name="l00046"></a>00046 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00047"></a><a class="code" href="structpopulation__compare.html">00047</a> <span class="keyword">struct </span><a class="code" href="structpopulation__compare.html">population_compare</a>
<a name="l00048"></a>00048 {
<a name="l00049"></a>00049   <span class="keywordtype">bool</span> operator() (<span class="keyword">const</span> <a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>* a,<span class="keyword">const</span> <a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>* b )<span class="keyword"> const</span>
<a name="l00050"></a>00050 <span class="keyword">  </span>{
<a name="l00051"></a>00051     <span class="keywordflow">return</span> *a &lt; *b;
<a name="l00052"></a>00052   }
<a name="l00053"></a>00053 };
<a name="l00054"></a>00054 
<a name="l00055"></a>00055 
<a name="l00056"></a>00056 <span class="comment">/* --------------------------------------------------------------------------*/</span>
<a name="l00068"></a>00068 <span class="comment">/* ----------------------------------------------------------------------------*/</span>
<a name="l00069"></a>00069 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00070"></a><a class="code" href="classpopulation.html">00070</a> <span class="keyword">class </span><a class="code" href="classpopulation.html">population</a>
<a name="l00071"></a>00071 {
<a name="l00072"></a>00072   <span class="keyword">public</span>:
<a name="l00073"></a>00073 
<a name="l00074"></a>00074     <span class="comment">/* --------------------------------------------------------------- *</span>
<a name="l00075"></a>00075 <span class="comment">     * --- Algumas definições básicas                                  *</span>
<a name="l00076"></a>00076 <span class="comment">     * --------------------------------------------------------------- */</span>
<a name="l00077"></a>00077 
<a name="l00078"></a>00078     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00082"></a>00082     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00083"></a><a class="code" href="classpopulation.html#a487317a079f4b94c650983ccbd0048a5">00083</a>     <span class="keyword">typedef</span> <span class="keyword">typename</span> std::vector&lt;individual&lt;_ty,_realTy&gt;*&gt; <a class="code" href="classpopulation.html#a487317a079f4b94c650983ccbd0048a5">_pop</a>;
<a name="l00084"></a>00084 
<a name="l00085"></a>00085     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00089"></a>00089     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00090"></a><a class="code" href="classpopulation.html#aa2f35e7dcc0553a7d2a96e5dca6105e0">00090</a>     <span class="keyword">typedef</span> <span class="keyword">typename</span> std::vector&lt;individual&lt;_ty,_realTy&gt;*&gt;::iterator <a class="code" href="classpopulation.html#aa2f35e7dcc0553a7d2a96e5dca6105e0">it_</a>; 
<a name="l00091"></a>00091 
<a name="l00092"></a>00092     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00096"></a>00096     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00097"></a><a class="code" href="classpopulation.html#afcea3753ae2b2e0211f8fdc919c51a71">00097</a>     <span class="keyword">typedef</span> <span class="keyword">typename</span> std::vector&lt;individual&lt;_ty,_realTy&gt;*&gt;::const_iterator <a class="code" href="classpopulation.html#afcea3753ae2b2e0211f8fdc919c51a71">const_it_</a>;
<a name="l00098"></a>00098 
<a name="l00099"></a>00099     <span class="comment">/* --------------------------------------------------------------- *</span>
<a name="l00100"></a>00100 <span class="comment">     * --- Construtores/Destrutores                                    *</span>
<a name="l00101"></a>00101 <span class="comment">     * --------------------------------------------------------------- */</span>
<a name="l00102"></a>00102 
<a name="l00103"></a>00103     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00109"></a>00109     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00110"></a>00110     <a class="code" href="classpopulation.html#aa497c7bcf82ec82f15cf0ca41f29c153">population</a> (<span class="keyword">const</span> <span class="keywordtype">int</span>&amp; number_ids = def::population::population_size);
<a name="l00111"></a>00111 
<a name="l00112"></a>00112     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00118"></a>00118     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00119"></a>00119     <a class="code" href="classpopulation.html#aa497c7bcf82ec82f15cf0ca41f29c153">population</a> (<span class="keyword">const</span> <a class="code" href="classpopulation.html">population&lt;_ty,_realTy&gt;</a>&amp; pop);
<a name="l00120"></a>00120 
<a name="l00121"></a>00121     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00125"></a>00125     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00126"></a>00126     <a class="code" href="classpopulation.html#a735c7c86f92155f0deb6034432086d37">~population</a>(<span class="keywordtype">void</span>);
<a name="l00127"></a>00127 
<a name="l00128"></a>00128     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00134"></a>00134     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00135"></a><a class="code" href="classpopulation.html#a15aee31f3669a3819a025d0c88fd559b">00135</a>     <span class="keywordtype">int</span> <a class="code" href="classpopulation.html#a15aee31f3669a3819a025d0c88fd559b">GetId</a> (<span class="keywordtype">void</span>)<span class="keyword"> const </span>{<span class="keywordflow">return</span> _id;}
<a name="l00136"></a>00136 
<a name="l00137"></a>00137     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00143"></a>00143     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00144"></a><a class="code" href="classpopulation.html#aa7803cea8fa30be9c9732d8e81f8aaf4">00144</a>     <span class="keywordtype">void</span> <a class="code" href="classpopulation.html#aa7803cea8fa30be9c9732d8e81f8aaf4">SetId</a> (<span class="keyword">const</span> <span class="keywordtype">int</span>&amp; new_id) {_id = new_id;}
<a name="l00145"></a>00145 
<a name="l00146"></a>00146     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00152"></a>00152     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00153"></a><a class="code" href="classpopulation.html#aa8d33d15eef1966482d052ff509bc638">00153</a>     <span class="keywordtype">int</span> <a class="code" href="classpopulation.html#aa8d33d15eef1966482d052ff509bc638">GetNumerOfIndividuals</a> (<span class="keywordtype">void</span>)<span class="keyword"> const </span>{<span class="keywordflow">return</span> _myPop.size();}
<a name="l00154"></a>00154 
<a name="l00155"></a>00155     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00161"></a>00161     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00162"></a><a class="code" href="classpopulation.html#a3c0a549de81a152a15f052e57f106a86">00162</a>     _realTy <a class="code" href="classpopulation.html#a3c0a549de81a152a15f052e57f106a86">GetAveragePerformance</a> (<span class="keywordtype">void</span>)<span class="keyword"> const </span>{<span class="keywordflow">return</span> _average;}
<a name="l00163"></a>00163 
<a name="l00164"></a>00164     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00170"></a>00170     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00171"></a><a class="code" href="classpopulation.html#a7fb6b0d19740560913aac2eb376c56fb">00171</a>     <span class="keywordtype">void</span> <a class="code" href="classpopulation.html#a7fb6b0d19740560913aac2eb376c56fb">SetAveragePerformance</a> (<span class="keyword">const</span> _realTy&amp; new_average) {_average = new_average;}
<a name="l00172"></a>00172 
<a name="l00173"></a>00173     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00179"></a>00179     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00180"></a><a class="code" href="classpopulation.html#ac7e0fd101523d1f1db34ae3484a30bf3">00180</a>     _realTy <a class="code" href="classpopulation.html#ac7e0fd101523d1f1db34ae3484a30bf3">GetSum</a> (<span class="keywordtype">void</span>) {<span class="keywordflow">return</span> _sum;}
<a name="l00181"></a>00181 
<a name="l00182"></a>00182     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00188"></a>00188     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00189"></a><a class="code" href="classpopulation.html#a80e34ba9884327ddc5bafbaedd32014b">00189</a>     <span class="keywordtype">void</span> <a class="code" href="classpopulation.html#a80e34ba9884327ddc5bafbaedd32014b">SetSum</a> (<span class="keyword">const</span> _realTy&amp; new_sum) {_sum = new_sum;}
<a name="l00190"></a>00190 
<a name="l00191"></a>00191     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00197"></a>00197     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00198"></a><a class="code" href="classpopulation.html#abe769cd333fa71228e6a89da1171fd93">00198</a>     _realTy <a class="code" href="classpopulation.html#abe769cd333fa71228e6a89da1171fd93">GetDeviation</a> (<span class="keywordtype">void</span>)<span class="keyword"> const </span>{<span class="keywordflow">return</span> _deviation;}
<a name="l00199"></a>00199 
<a name="l00200"></a>00200     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00206"></a>00206     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00207"></a><a class="code" href="classpopulation.html#ad0b1614ed94b9eb82a8ca0e24bdc603b">00207</a>     <span class="keywordtype">void</span> <a class="code" href="classpopulation.html#ad0b1614ed94b9eb82a8ca0e24bdc603b">SetDeviation</a> (<span class="keyword">const</span> _realTy&amp; new_deviation) { _deviation = new_deviation; }
<a name="l00208"></a>00208 
<a name="l00209"></a>00209     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00215"></a>00215     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00216"></a><a class="code" href="classpopulation.html#a2ddcfb41305717b30051f0aa0a8e240c">00216</a>     <span class="keywordtype">void</span> <a class="code" href="classpopulation.html#a2ddcfb41305717b30051f0aa0a8e240c">SendGenerationDataToStream</a> (std::ostream&amp; os)<span class="keyword"> const </span>{os&lt;&lt;_bestId-&gt;GetID() &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt;_bestId-&gt;GetValue() &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt;_worseId-&gt;GetID() &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt; _worseId-&gt;GetValue() &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt; _average &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt; _deviation &lt;&lt; std::endl;}
<a name="l00217"></a>00217 
<a name="l00218"></a>00218     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00224"></a>00224     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00225"></a><a class="code" href="classpopulation.html#a4751584859b70770ae44717a43f9ab95">00225</a>     <a class="code" href="classpopulation.html#afcea3753ae2b2e0211f8fdc919c51a71">const_it_</a> <a class="code" href="classpopulation.html#a4751584859b70770ae44717a43f9ab95">begin</a> (<span class="keywordtype">void</span>)<span class="keyword"> const </span>{<span class="keywordflow">return</span> _myPop.begin();}
<a name="l00226"></a>00226 
<a name="l00227"></a>00227     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00233"></a>00233     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00234"></a><a class="code" href="classpopulation.html#a38318f9ca5c607490f4d6e92b54d8734">00234</a>     <a class="code" href="classpopulation.html#afcea3753ae2b2e0211f8fdc919c51a71">const_it_</a> <a class="code" href="classpopulation.html#a38318f9ca5c607490f4d6e92b54d8734">end</a> (<span class="keywordtype">void</span>)<span class="keyword"> const </span>{<span class="keywordflow">return</span> _myPop.end();}
<a name="l00235"></a>00235 
<a name="l00236"></a>00236     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00242"></a>00242     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00243"></a><a class="code" href="classpopulation.html#a7c7bcf224b99227f6ab381dbc9f37c2c">00243</a>     <a class="code" href="classpopulation.html#aa2f35e7dcc0553a7d2a96e5dca6105e0">it_</a> <a class="code" href="classpopulation.html#a7c7bcf224b99227f6ab381dbc9f37c2c">begin</a> (<span class="keywordtype">void</span>) {<span class="keywordflow">return</span> _myPop.begin();}
<a name="l00244"></a>00244 
<a name="l00245"></a>00245     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00251"></a>00251     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00252"></a><a class="code" href="classpopulation.html#a42a620c96d521b7dcbd091c086258a4c">00252</a>     <a class="code" href="classpopulation.html#aa2f35e7dcc0553a7d2a96e5dca6105e0">it_</a> <a class="code" href="classpopulation.html#a42a620c96d521b7dcbd091c086258a4c">end</a> (<span class="keywordtype">void</span>) {<span class="keywordflow">return</span> _myPop.end();}
<a name="l00253"></a>00253 
<a name="l00254"></a>00254     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00260"></a>00260     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00261"></a>00261     <span class="keywordtype">void</span> <a class="code" href="classpopulation.html#ac7b74f6cbb098394df06e1c84de0f260">SetNewIndividuals</a> (<span class="keyword">const</span> <a class="code" href="classpopulation.html#a487317a079f4b94c650983ccbd0048a5">_pop</a>&amp; new_pop); 
<a name="l00262"></a>00262 
<a name="l00263"></a>00263     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00269"></a>00269     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00270"></a><a class="code" href="classpopulation.html#a251eb4e8235f4c456e2940fe4a0e4678">00270</a>     <a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>* <a class="code" href="classpopulation.html#a251eb4e8235f4c456e2940fe4a0e4678">GetWorseId</a> (<span class="keywordtype">void</span>)<span class="keyword"> const </span>{<span class="keywordflow">return</span> _worseId;}
<a name="l00271"></a>00271 
<a name="l00272"></a>00272     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00278"></a>00278     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00279"></a><a class="code" href="classpopulation.html#a9b2b5de6f220010a0d6c780b7ce04e5b">00279</a>     <a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>* <a class="code" href="classpopulation.html#a9b2b5de6f220010a0d6c780b7ce04e5b">GetBestId</a> (<span class="keywordtype">void</span>)<span class="keyword"> const </span>{<span class="keywordflow">return</span> _bestId;}
<a name="l00280"></a>00280 
<a name="l00281"></a>00281     <span class="comment">/* --------------------------------------------------------------- *</span>
<a name="l00282"></a>00282 <span class="comment">     * --- Sobrecarga de operadores                                    *</span>
<a name="l00283"></a>00283 <span class="comment">     * --------------------------------------------------------------- */</span>
<a name="l00284"></a>00284 
<a name="l00285"></a>00285     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00293"></a>00293     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00294"></a><a class="code" href="classpopulation.html#a6ca81f5193818b065f792fac9b51f6e3">00294</a>     <a class="code" href="classpopulation.html#afcea3753ae2b2e0211f8fdc919c51a71">const_it_</a> <a class="code" href="classpopulation.html#a6ca81f5193818b065f792fac9b51f6e3">operator [] </a>(<span class="keyword">const</span> <span class="keywordtype">int</span>&amp; indice)<span class="keyword"> const </span>{<a class="code" href="classpopulation.html#afcea3753ae2b2e0211f8fdc919c51a71">const_it_</a> it = _myPop.begin();<span class="keywordflow">if</span>((indice&gt;=0)&amp;&amp;(indice&lt;_myPop.size())) it += indice;<span class="keywordflow">return</span> it;}
<a name="l00295"></a>00295 
<a name="l00296"></a>00296     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00304"></a>00304     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00305"></a>00305     <span class="keywordtype">bool</span> <a class="code" href="classpopulation.html#a1a847bb47928abf5a0d0a7e4a2ec8c5f">operator == </a>(<span class="keyword">const</span> <a class="code" href="classpopulation.html">population&lt;_ty,_realTy&gt;</a>&amp; pop) <span class="keyword">const</span>;
<a name="l00306"></a>00306 
<a name="l00307"></a>00307     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00315"></a>00315     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00316"></a><a class="code" href="classpopulation.html#a14c45c3fe1905bcb673919ae251087a9">00316</a>     <a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>* <a class="code" href="classpopulation.html#a6ca81f5193818b065f792fac9b51f6e3">operator[] </a>(<span class="keyword">const</span> <span class="keywordtype">int</span>&amp; indice) {<span class="keywordflow">return</span> (((indice&gt;=0)&amp;&amp;(indice&lt;_myPop.size()))?_myPop[indice]:NULL);}
<a name="l00317"></a>00317 
<a name="l00318"></a>00318     <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T,<span class="keyword">typename</span> U&gt; <span class="keyword">friend</span>
<a name="l00319"></a>00319     std::istream&amp; <a class="code" href="classpopulation.html#aa6fb88900759771dccfd85d21785fd1b" title="Sobrecarga de operadores.">operator &gt;&gt; </a>(std::istream&amp; is, <a class="code" href="classpopulation.html">population&lt;T,U&gt;</a>&amp; pop);
<a name="l00320"></a>00320 
<a name="l00321"></a>00321     <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T,<span class="keyword">typename</span> U&gt; <span class="keyword">friend</span>
<a name="l00322"></a>00322     std::ostream&amp; operator &lt;&lt; (std::ostream&amp; os, const population&lt;T,U&gt;&amp; pop);
<a name="l00323"></a>00323 
<a name="l00324"></a>00324     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00328"></a>00328     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00329"></a>00329     <span class="keywordtype">void</span> <a class="code" href="classpopulation.html#aba14d0fb6ceb7499c4fc4838889ba918">PrintPairs</a> (<span class="keywordtype">void</span>) <span class="keyword">const</span>;
<a name="l00330"></a>00330 
<a name="l00331"></a>00331     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00335"></a>00335     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00336"></a>00336     <span class="keywordtype">void</span> <a class="code" href="classpopulation.html#a20b40816fade14ec740cdc3f22d8066e">GeneratePopulation</a> (<span class="keywordtype">void</span>);
<a name="l00337"></a>00337 
<a name="l00338"></a>00338     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00342"></a>00342     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00343"></a>00343     <span class="keywordtype">void</span> <a class="code" href="classpopulation.html#a10331bd5a9f8f4879cea62ee8b1f28c3">SetIndividualsValue</a> (<span class="keywordtype">void</span>);
<a name="l00344"></a>00344 
<a name="l00345"></a>00345     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00349"></a>00349     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00350"></a><a class="code" href="classpopulation.html#a83be39057000008244d4d7bc947d09fa">00350</a>     <span class="keywordtype">void</span> <a class="code" href="classpopulation.html#a83be39057000008244d4d7bc947d09fa">SortPopulation</a> (<span class="keywordtype">void</span>) {<a class="code" href="structpopulation__compare.html">population_compare&lt;_ty,_realTy&gt;</a> object_compare;std::sort(_myPop.begin(), _myPop.end(),object_compare);}
<a name="l00351"></a>00351 
<a name="l00352"></a>00352     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00356"></a>00356     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00357"></a>00357     <span class="keywordtype">void</span> <a class="code" href="classpopulation.html#a6953ec7e3cd8aa654a1621c515e0d166">CleanPopulation</a> (<span class="keywordtype">void</span>);
<a name="l00358"></a>00358 
<a name="l00359"></a>00359     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00367"></a>00367     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00368"></a>00368     <span class="keywordtype">bool</span> <a class="code" href="classpopulation.html#a23a6d7fca0c7cbaffdcf6cb6cf3239a9">AddIndividualToPopulation</a> (<a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>* newId);
<a name="l00369"></a>00369 
<a name="l00370"></a>00370     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00378"></a>00378     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00379"></a>00379     <span class="keywordtype">bool</span> <a class="code" href="classpopulation.html#a1c227882a579ffe0b2fb049518e1eb85">RemoveIndividualAt</a> (<span class="keyword">const</span> <span class="keywordtype">int</span>&amp; pos);
<a name="l00380"></a>00380 
<a name="l00381"></a>00381     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00387"></a>00387     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00388"></a>00388     <span class="keywordtype">void</span> <a class="code" href="classpopulation.html#aa2cbedb9d90d9c660b4a4369857e1c96">SetNullIndividualAt</a> (<span class="keyword">const</span> <span class="keywordtype">int</span>&amp; pos);
<a name="l00389"></a>00389 
<a name="l00390"></a>00390     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00394"></a>00394     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00395"></a>00395     <span class="keywordtype">void</span> <a class="code" href="classpopulation.html#a7dd1a669bdbc71381ad2d01ca35c24ae">UpdateData</a> (<span class="keywordtype">void</span>);
<a name="l00396"></a>00396 
<a name="l00397"></a>00397   <span class="keyword">private</span>:
<a name="l00398"></a>00398 
<a name="l00399"></a>00399     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00403"></a>00403     <span class="comment">/* ----------------------------------------*/</span>
<a name="l00404"></a>00404     <span class="keywordtype">void</span> UpdateDeviation (<span class="keywordtype">void</span>);
<a name="l00405"></a>00405 
<a name="l00406"></a>00406     <span class="keywordtype">int</span> _id;<span class="comment">//Inteiro que identifica a população</span>
<a name="l00407"></a>00407     <a class="code" href="classpopulation.html#a487317a079f4b94c650983ccbd0048a5">_pop</a> _myPop;<span class="comment">//Populacao de indivivíduos</span>
<a name="l00408"></a>00408     <a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>* _bestId;
<a name="l00409"></a>00409     <a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>* _worseId;<span class="comment">//Respectivily best and worse individuals of the consteiner _myPop</span>
<a name="l00410"></a>00410     _realTy _average;<span class="comment">//Average value of the objective function of the population</span>
<a name="l00411"></a>00411     _realTy _deviation;<span class="comment">//Variãncia do valor da função objetivo na população</span>
<a name="l00412"></a>00412     _realTy _sum;<span class="comment">//Soma do valor da função objetivo para todos os indivíduos</span>
<a name="l00413"></a>00413 
<a name="l00414"></a>00414 };
<a name="l00415"></a>00415 
<a name="l00416"></a>00416 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00417"></a><a class="code" href="classpopulation.html#aba14d0fb6ceb7499c4fc4838889ba918">00417</a> <span class="keywordtype">void</span> <a class="code" href="classpopulation.html#aba14d0fb6ceb7499c4fc4838889ba918">population&lt;_ty,_realTy&gt;::PrintPairs</a> (<span class="keywordtype">void</span>)<span class="keyword"> const</span>
<a name="l00418"></a>00418 <span class="keyword"></span>{
<a name="l00419"></a>00419   <span class="keywordflow">for</span> (<a class="code" href="classpopulation.html#afcea3753ae2b2e0211f8fdc919c51a71">const_it_</a> it = _myPop.begin(); it != _myPop.end(); ++it)
<a name="l00420"></a>00420   {
<a name="l00421"></a>00421     std::cout &lt;&lt; (*it)-&gt;GetID() &lt;&lt; <span class="stringliteral">&quot; casou com &quot;</span>;
<a name="l00422"></a>00422   <span class="keywordflow">if</span> ((*it)-&gt;GetPair()==NULL)
<a name="l00423"></a>00423     std::cout &lt;&lt; <span class="stringliteral">&quot;ninguem&quot;</span> &lt;&lt; std::endl;
<a name="l00424"></a>00424   <span class="keywordflow">else</span>
<a name="l00425"></a>00425     std::cout &lt;&lt; (*it)-&gt;GetPair()-&gt;GetID() &lt;&lt; std::endl;
<a name="l00426"></a>00426   }
<a name="l00427"></a>00427 }
<a name="l00428"></a>00428 
<a name="l00429"></a>00429 <span class="comment">/* --------------------------------------------------------------- *</span>
<a name="l00430"></a>00430 <span class="comment"> * --- Construtores/Destrutores                                    *</span>
<a name="l00431"></a>00431 <span class="comment"> * --------------------------------------------------------------- */</span>
<a name="l00432"></a>00432 
<a name="l00433"></a>00433 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00434"></a><a class="code" href="classpopulation.html#aa497c7bcf82ec82f15cf0ca41f29c153">00434</a> <a class="code" href="classpopulation.html#aa497c7bcf82ec82f15cf0ca41f29c153">population&lt;_ty,_realTy&gt;::population</a> (<span class="keyword">const</span> <span class="keywordtype">int</span>&amp; number_ids)
<a name="l00435"></a>00435 {
<a name="l00436"></a>00436   <span class="keywordtype">int</span> number_ = number_ids;
<a name="l00437"></a>00437   <span class="keywordtype">int</span> count = 0;
<a name="l00438"></a>00438   <span class="keywordflow">while</span>(number_--)
<a name="l00439"></a>00439   {
<a name="l00440"></a>00440     _myPop.push_back(<span class="keyword">new</span> <a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>(count++));
<a name="l00441"></a>00441   }
<a name="l00442"></a>00442   _bestId = _worseId = NULL;
<a name="l00443"></a>00443   _average = _deviation = 0;
<a name="l00444"></a>00444   _id = 0;
<a name="l00445"></a>00445   _sum = 0;
<a name="l00446"></a>00446 }
<a name="l00447"></a>00447 
<a name="l00448"></a>00448 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00449"></a><a class="code" href="classpopulation.html#ab7b5dad1173b0da5b177e6253b66a071">00449</a> <a class="code" href="classpopulation.html#aa497c7bcf82ec82f15cf0ca41f29c153">population&lt;_ty,_realTy&gt;::population</a> (<span class="keyword">const</span> <a class="code" href="classpopulation.html">population&lt;_ty,_realTy&gt;</a>&amp; pop)
<a name="l00450"></a>00450 {
<a name="l00451"></a>00451   <span class="comment">//begin debug</span>
<a name="l00452"></a>00452   std::cout &lt;&lt; <span class="stringliteral">&quot;Entrou no contrutor de copia da população&quot;</span> &lt;&lt; std::endl;
<a name="l00453"></a>00453  <span class="comment">//end debug </span>
<a name="l00454"></a>00454   <span class="keywordflow">for</span>(<a class="code" href="classpopulation.html#afcea3753ae2b2e0211f8fdc919c51a71">const_it_</a> it = pop.<a class="code" href="classpopulation.html#a4751584859b70770ae44717a43f9ab95">begin</a>(); it != pop.<a class="code" href="classpopulation.html#a38318f9ca5c607490f4d6e92b54d8734">end</a>(); ++it)
<a name="l00455"></a>00455   {
<a name="l00456"></a>00456     this-&gt;_myPop.push_back(<span class="keyword">new</span> <a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>());
<a name="l00457"></a>00457     (*this-&gt;_myPop.back()) = (*(*it));
<a name="l00458"></a>00458     <span class="keywordflow">if</span> (*it == pop.<a class="code" href="classpopulation.html#a251eb4e8235f4c456e2940fe4a0e4678">GetWorseId</a>())
<a name="l00459"></a>00459       this-&gt;_worseId = this-&gt;<span class="keyword">operator</span>[](_myPop.size()-1);
<a name="l00460"></a>00460     <span class="keywordflow">if</span> (*it == pop.<a class="code" href="classpopulation.html#a9b2b5de6f220010a0d6c780b7ce04e5b">GetBestId</a>())
<a name="l00461"></a>00461       this-&gt;_bestId = this-&gt;<span class="keyword">operator</span>[](_myPop.size()-1);
<a name="l00462"></a>00462   }
<a name="l00463"></a>00463   this-&gt;_average = pop.<a class="code" href="classpopulation.html#a3c0a549de81a152a15f052e57f106a86">GetAveragePerformance</a>();
<a name="l00464"></a>00464   this-&gt;_deviation = pop.<a class="code" href="classpopulation.html#abe769cd333fa71228e6a89da1171fd93">GetDeviation</a>();
<a name="l00465"></a>00465   this-&gt;_id = pop.<a class="code" href="classpopulation.html#a15aee31f3669a3819a025d0c88fd559b">GetId</a>();
<a name="l00466"></a>00466   this-&gt;_sum = pop.<a class="code" href="classpopulation.html#ac7e0fd101523d1f1db34ae3484a30bf3">GetSum</a>();
<a name="l00467"></a>00467 }
<a name="l00468"></a>00468 
<a name="l00469"></a>00469 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00470"></a><a class="code" href="classpopulation.html#a735c7c86f92155f0deb6034432086d37">00470</a> <a class="code" href="classpopulation.html#a735c7c86f92155f0deb6034432086d37">population&lt;_ty,_realTy&gt;::~population</a> (<span class="keywordtype">void</span>)
<a name="l00471"></a>00471 {
<a name="l00472"></a>00472   
<a name="l00473"></a>00473   <span class="comment">//begin debug</span>
<a name="l00474"></a>00474   std::cout &lt;&lt; <span class="stringliteral">&quot;Entrou no destrutor da população.&quot;</span> &lt;&lt; std::endl;
<a name="l00475"></a>00475  <span class="comment">//end debug </span>
<a name="l00476"></a>00476   <span class="keywordflow">for</span> (<a class="code" href="classpopulation.html#aa2f35e7dcc0553a7d2a96e5dca6105e0">it_</a> it = _myPop.begin(); it != _myPop.end(); ++it)
<a name="l00477"></a>00477     <span class="keyword">delete</span> *it;
<a name="l00478"></a>00478 }
<a name="l00479"></a>00479 
<a name="l00480"></a>00480 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00481"></a><a class="code" href="classpopulation.html#a7dd1a669bdbc71381ad2d01ca35c24ae">00481</a> <span class="keywordtype">void</span> <a class="code" href="classpopulation.html#a7dd1a669bdbc71381ad2d01ca35c24ae">population&lt;_ty,_realTy&gt;::UpdateData</a> (<span class="keywordtype">void</span>)
<a name="l00482"></a>00482 {
<a name="l00483"></a>00483   _average=0;
<a name="l00484"></a>00484   _bestId = _worseId = NULL;
<a name="l00485"></a>00485   <span class="keywordflow">for</span> (<a class="code" href="classpopulation.html#aa2f35e7dcc0553a7d2a96e5dca6105e0">it_</a> it = _myPop.begin(); it != _myPop.end(); ++it)
<a name="l00486"></a>00486   {
<a name="l00487"></a>00487     _average += (*it)-&gt;GetValue();
<a name="l00488"></a>00488 
<a name="l00489"></a>00489     <span class="keywordflow">if</span> (_bestId != NULL )
<a name="l00490"></a>00490     {
<a name="l00491"></a>00491       <span class="keywordflow">if</span> ((*it)-&gt;GetValue() &lt; _bestId-&gt;GetValue())
<a name="l00492"></a>00492         _bestId = *it;
<a name="l00493"></a>00493     }
<a name="l00494"></a>00494     <span class="keywordflow">else</span>
<a name="l00495"></a>00495       _bestId = *it;
<a name="l00496"></a>00496 
<a name="l00497"></a>00497     <span class="keywordflow">if</span> (_worseId != NULL)
<a name="l00498"></a>00498     {
<a name="l00499"></a>00499       <span class="keywordflow">if</span> ( (*it)-&gt;GetValue() &gt; _worseId-&gt;GetValue())
<a name="l00500"></a>00500         _worseId = *it;
<a name="l00501"></a>00501     }
<a name="l00502"></a>00502     <span class="keywordflow">else</span>
<a name="l00503"></a>00503       _worseId = *it;
<a name="l00504"></a>00504 
<a name="l00505"></a>00505 
<a name="l00506"></a>00506   }
<a name="l00507"></a>00507   _sum = _average;
<a name="l00508"></a>00508   _average /= _myPop.size();
<a name="l00509"></a>00509   UpdateDeviation();
<a name="l00510"></a>00510 }
<a name="l00511"></a>00511 
<a name="l00512"></a>00512 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00513"></a>00513 <span class="keywordtype">void</span> <a class="code" href="classpopulation.html">population&lt;_ty,_realTy&gt;::UpdateDeviation</a>(<span class="keywordtype">void</span>)
<a name="l00514"></a>00514 {
<a name="l00515"></a>00515   _deviation = 0;
<a name="l00516"></a>00516   <span class="keywordflow">for</span> (<a class="code" href="classpopulation.html#aa2f35e7dcc0553a7d2a96e5dca6105e0">it_</a> it = _myPop.begin(); it != _myPop.end(); ++it)
<a name="l00517"></a>00517     _deviation += pow ((*it)-&gt;GetValue()-_average,2);
<a name="l00518"></a>00518 
<a name="l00519"></a>00519   _deviation /= (_myPop.size()-1);
<a name="l00520"></a>00520   
<a name="l00521"></a>00521   _deviation = pow (_deviation,0.5);
<a name="l00522"></a>00522 }
<a name="l00523"></a>00523 
<a name="l00524"></a>00524 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00525"></a><a class="code" href="classpopulation.html#a20b40816fade14ec740cdc3f22d8066e">00525</a> <span class="keywordtype">void</span> <a class="code" href="classpopulation.html#a20b40816fade14ec740cdc3f22d8066e">population&lt;_ty,_realTy&gt;::GeneratePopulation</a> (<span class="keywordtype">void</span>)
<a name="l00526"></a>00526 {
<a name="l00527"></a>00527   <span class="keywordflow">for</span> (<a class="code" href="classpopulation.html#aa2f35e7dcc0553a7d2a96e5dca6105e0">it_</a> it = _myPop.begin(); it != _myPop.end(); ++it)
<a name="l00528"></a>00528     (*it)-&gt;GeneratePosition();
<a name="l00529"></a>00529 }
<a name="l00530"></a>00530 
<a name="l00531"></a>00531 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00532"></a><a class="code" href="classpopulation.html#a10331bd5a9f8f4879cea62ee8b1f28c3">00532</a> <span class="keywordtype">void</span> <a class="code" href="classpopulation.html#a10331bd5a9f8f4879cea62ee8b1f28c3">population&lt;_ty,_realTy&gt;::SetIndividualsValue</a> (<span class="keywordtype">void</span>)
<a name="l00533"></a>00533 {
<a name="l00534"></a>00534   <span class="keywordflow">for</span> (<a class="code" href="classpopulation.html#aa2f35e7dcc0553a7d2a96e5dca6105e0">it_</a> it = _myPop.begin(); it != _myPop.end(); ++it)
<a name="l00535"></a>00535   {
<a name="l00536"></a>00536     std::vector&lt;_realTy&gt; position = (*it)-&gt;GetRealPosition();
<a name="l00537"></a>00537     (*it)-&gt;SetValue(GetObjectiveFunction(position));
<a name="l00538"></a>00538   }
<a name="l00539"></a>00539   <a class="code" href="classpopulation.html#a7dd1a669bdbc71381ad2d01ca35c24ae">UpdateData</a>();
<a name="l00540"></a>00540 }
<a name="l00541"></a>00541 
<a name="l00542"></a>00542 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00543"></a>00543 <span class="keywordtype">void</span> <a class="code" href="classpopulation.html#ac7b74f6cbb098394df06e1c84de0f260">population&lt;_ty,_realTy&gt;::SetNewIndividuals</a> (<span class="keyword">const</span> <span class="keyword">typename</span> <a class="code" href="classpopulation.html">population&lt;_ty,_realTy&gt;::_pop</a>&amp; new_pop)
<a name="l00544"></a>00544 {
<a name="l00545"></a>00545   <a class="code" href="classpopulation.html#a6953ec7e3cd8aa654a1621c515e0d166">CleanPopulation</a>();
<a name="l00546"></a>00546   <span class="keywordtype">int</span> count = 0;
<a name="l00547"></a>00547   <span class="keywordflow">for</span> (<a class="code" href="classpopulation.html#afcea3753ae2b2e0211f8fdc919c51a71">const_it_</a> it = new_pop.<a class="code" href="classpopulation.html#a4751584859b70770ae44717a43f9ab95">begin</a>(); it != new_pop.<a class="code" href="classpopulation.html#a38318f9ca5c607490f4d6e92b54d8734">end</a>(); ++it)
<a name="l00548"></a>00548   {
<a name="l00549"></a>00549     _myPop.push_back(*it);
<a name="l00550"></a>00550   }
<a name="l00551"></a>00551   
<a name="l00552"></a>00552 }
<a name="l00553"></a>00553 
<a name="l00554"></a>00554 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00555"></a><a class="code" href="classpopulation.html#a6953ec7e3cd8aa654a1621c515e0d166">00555</a> <span class="keywordtype">void</span> <a class="code" href="classpopulation.html#a6953ec7e3cd8aa654a1621c515e0d166">population&lt;_ty,_realTy&gt;::CleanPopulation</a> (<span class="keywordtype">void</span>)
<a name="l00556"></a>00556 {
<a name="l00557"></a>00557   <span class="keywordflow">for</span> (<a class="code" href="classpopulation.html#aa2f35e7dcc0553a7d2a96e5dca6105e0">it_</a> it = _myPop.begin(); it != _myPop.end(); ++it)
<a name="l00558"></a>00558     <span class="keyword">delete</span> *it;
<a name="l00559"></a>00559   _myPop.clear();
<a name="l00560"></a>00560 }
<a name="l00561"></a>00561 
<a name="l00562"></a>00562 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00563"></a><a class="code" href="classpopulation.html#a23a6d7fca0c7cbaffdcf6cb6cf3239a9">00563</a> <span class="keywordtype">bool</span> <a class="code" href="classpopulation.html#a23a6d7fca0c7cbaffdcf6cb6cf3239a9">population&lt;_ty,_realTy&gt;::AddIndividualToPopulation</a> (<a class="code" href="classindividual.html">individual&lt;_ty,_realTy&gt;</a>* newId)
<a name="l00564"></a>00564 {
<a name="l00565"></a>00565   <span class="keywordflow">if</span>(_myPop.size() &gt;= def::population::population_size)
<a name="l00566"></a>00566     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00567"></a>00567   <span class="keywordflow">else</span>
<a name="l00568"></a>00568   {
<a name="l00569"></a>00569     _myPop.push_back(newId);
<a name="l00570"></a>00570     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00571"></a>00571   }
<a name="l00572"></a>00572 }
<a name="l00573"></a>00573 
<a name="l00574"></a>00574 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00575"></a><a class="code" href="classpopulation.html#a1c227882a579ffe0b2fb049518e1eb85">00575</a> <span class="keywordtype">bool</span> <a class="code" href="classpopulation.html#a1c227882a579ffe0b2fb049518e1eb85">population&lt;_ty,_realTy&gt;::RemoveIndividualAt</a> (<span class="keyword">const</span> <span class="keywordtype">int</span>&amp; pos)
<a name="l00576"></a>00576 {
<a name="l00577"></a>00577   <span class="keywordflow">if</span> (pos&lt;0 || pos &gt;= _myPop.size())
<a name="l00578"></a>00578     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00579"></a>00579   <span class="keywordflow">else</span>
<a name="l00580"></a>00580   {
<a name="l00581"></a>00581     <a class="code" href="classpopulation.html#aa2f35e7dcc0553a7d2a96e5dca6105e0">it_</a> toRemove = _myPop.begin()+pos;
<a name="l00582"></a>00582     _myPop.erase(toRemove);
<a name="l00583"></a>00583     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00584"></a>00584   }
<a name="l00585"></a>00585 }
<a name="l00586"></a>00586 
<a name="l00588"></a>00588 
<a name="l00589"></a>00589 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T,<span class="keyword">typename</span> U&gt; 
<a name="l00590"></a><a class="code" href="population_8h.html#aa6fb88900759771dccfd85d21785fd1b">00590</a> std::istream&amp; <a class="code" href="coordinate_8h.html#aacb2e8f6ef327786248a961828b53fa5">operator &gt;&gt; </a>(std::istream&amp; is, <a class="code" href="classpopulation.html">population&lt;T,U&gt;</a>&amp; pop)
<a name="l00591"></a>00591 {
<a name="l00592"></a>00592   is &gt;&gt; pop._id;
<a name="l00593"></a>00593   is &gt;&gt; pop._average;
<a name="l00594"></a>00594   is &gt;&gt; pop._deviation;
<a name="l00595"></a>00595   is &gt;&gt; pop._sum;
<a name="l00596"></a>00596   <span class="keywordtype">int</span> population_size;
<a name="l00597"></a>00597   is &gt;&gt; population_size;
<a name="l00598"></a>00598   pop._myPop.clear();<span class="comment">//limpa o conteiner para a inserção dos novos indivíduos</span>
<a name="l00599"></a>00599   <span class="keywordflow">for</span> (;population_size &gt; 0; --population_size)
<a name="l00600"></a>00600   {
<a name="l00601"></a>00601     <a class="code" href="classindividual.html">individual&lt;T,U&gt;</a>* new_id = <span class="keyword">new</span> <a class="code" href="classindividual.html">individual&lt;T,U&gt;</a>();
<a name="l00602"></a>00602     is &gt;&gt; *new_id;
<a name="l00603"></a>00603     pop._myPop.push_back(new_id); 
<a name="l00604"></a>00604   }
<a name="l00605"></a>00605   <span class="keywordflow">return</span> is;
<a name="l00606"></a>00606 }
<a name="l00607"></a>00607 
<a name="l00608"></a>00608 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T,<span class="keyword">typename</span> U&gt; 
<a name="l00609"></a>00609 std::ostream&amp; operator &lt;&lt; (std::ostream&amp; os, const population&lt;T,U&gt;&amp; pop)
<a name="l00610"></a>00610 {
<a name="l00611"></a>00611   os &lt;&lt; pop._id &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt; pop._average &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt; pop._deviation &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt; pop._sum &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt; pop._myPop.size() &lt;&lt; <span class="stringliteral">&quot; &quot;</span>;
<a name="l00612"></a>00612   <span class="keywordflow">for</span> (<span class="keyword">typename</span> <a class="code" href="classpopulation.html">population&lt;T,U&gt;::const_it_</a> it = pop.begin(); it != pop.end(); ++it)
<a name="l00613"></a>00613     os &lt;&lt; *(*it);
<a name="l00614"></a>00614    <span class="keywordflow">return</span> os;
<a name="l00615"></a>00615 
<a name="l00616"></a>00616 }
<a name="l00617"></a>00617 
<a name="l00618"></a>00618 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00619"></a><a class="code" href="classpopulation.html#a1a847bb47928abf5a0d0a7e4a2ec8c5f">00619</a> <span class="keywordtype">bool</span> <a class="code" href="classpopulation.html#a1a847bb47928abf5a0d0a7e4a2ec8c5f">population&lt;_ty,_realTy&gt;::operator == </a>(<span class="keyword">const</span> <a class="code" href="classpopulation.html">population&lt;_ty,_realTy&gt;</a>&amp; pop)<span class="keyword"> const</span>
<a name="l00620"></a>00620 <span class="keyword"></span>{
<a name="l00621"></a>00621   <span class="keywordflow">if</span> (pop.<a class="code" href="classpopulation.html#aa8d33d15eef1966482d052ff509bc638">GetNumerOfIndividuals</a>() != this-&gt;<a class="code" href="classpopulation.html#aa8d33d15eef1966482d052ff509bc638">GetNumerOfIndividuals</a>())
<a name="l00622"></a>00622     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00623"></a>00623 
<a name="l00624"></a>00624   <span class="keywordtype">bool</span> ret = <span class="keyword">true</span>;
<a name="l00625"></a>00625   <span class="keywordflow">for</span> (<span class="keywordtype">int</span> indice = 0; indice != _myPop.size(); ++indice) 
<a name="l00626"></a>00626   {
<a name="l00627"></a>00627     ret = ( *(*this)[indice] == *pop[indice] );
<a name="l00628"></a>00628     <span class="keywordflow">if</span> (!ret)
<a name="l00629"></a>00629       <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00630"></a>00630   }
<a name="l00631"></a>00631   <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00632"></a>00632 }
<a name="l00633"></a>00633 
<a name="l00634"></a>00634 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _ty,<span class="keyword">typename</span> _realTy&gt;
<a name="l00635"></a><a class="code" href="classpopulation.html#aa2cbedb9d90d9c660b4a4369857e1c96">00635</a> <span class="keywordtype">void</span> <a class="code" href="classpopulation.html#aa2cbedb9d90d9c660b4a4369857e1c96">population&lt;_ty,_realTy&gt;::SetNullIndividualAt</a> (<span class="keyword">const</span> <span class="keywordtype">int</span>&amp; pos)
<a name="l00636"></a>00636 {
<a name="l00637"></a>00637   <span class="keywordflow">if</span> (pos &lt; 0 || pos &gt; _myPop.size()-1)
<a name="l00638"></a>00638     <span class="keywordflow">return</span>;
<a name="l00639"></a>00639 
<a name="l00640"></a>00640   <a class="code" href="classpopulation.html#aa2f35e7dcc0553a7d2a96e5dca6105e0">it_</a> it = _myPop.begin();
<a name="l00641"></a>00641   it += pos;
<a name="l00642"></a>00642   *it = NULL;
<a name="l00643"></a>00643 }
<a name="l00644"></a>00644 
<a name="l00645"></a>00645 <span class="preprocessor">#endif</span>
</pre></div></div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>Todos</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Arquivos</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Funções</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Variáveis</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Definições de Tipos</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Amigas</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr class="footer"/><address style="text-align: right;"><small>Gerado em Sat Oct 30 13:47:50 2010 por&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>
